/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rational.parser.operation;

import org.rational.parser.expression.Expression;
import org.rational.parser.type.Type;

/**
 *
 * @author Overmind
 */
public abstract class BinaryOperation<R, F, S>
    extends Operation
{
    public BinaryOperation(int priority, String symbol, Type<R> resultType,
            Type<F> firstArgumentType, Type<S> secondArgumentType)
    {
        super(priority, new Expression(Expression.DEFAULT_ARGUMENT_SYMBOL + 
                symbol + Expression.DEFAULT_ARGUMENT_SYMBOL), 
                resultType, new Type[] {firstArgumentType, secondArgumentType});
    }

    @Override
    protected final Object calculateOfObjects(Object[] arguments)
    {
        return calculate((F)arguments[0], (S)arguments[1]);
    }
    
    public abstract R calculate(F first, S second);
}
